from time import sleep
import math
import turtle as graphing
def main():
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	usesw="y"
	while usesw=="y":
		print("IGEM TecCEM_HS")
		print("SDSseeker")
		print("Guadalupeware")
		choose=""
		while choose=="":
			print("What measurement do you want?")
			print("For predicting PH basing on the surface of the lake, type A")
			print("For predicting PH basing on the deep, type B, (only availible for the area near the dam)")
			print("For predicting the percentage of SDS present in a solution with Akylsulfatse after some time, type C")
			print("For predicting the PH of a solution with SDS and akylsulfatse after some time, type D")
			choose=str(input("Type the letter correspnding with your slection: "))
			if choose!="A"and choose!="B" and choose!="C" and choose!="D":
				choose=""
		if choose=="A":
			surfacePH()
		elif choose=="B":
			deepPH()
		elif choose=="C":
			degradation()
		else:
			degradationPH()
		print("")
		print("Do you want another measurement?")
		print("If yes type: y")
		print("If not type any letter")
		usesw=str(input("Type your selection: "))
		if usesw=="y":
			print("")
			print("")
			print("")
			print("")
			print("")
			print("")
			print("")
			print("")
			print("")
			print("")
	print("")
	print("")
	print("")
	print("")
	print("")
	print("Thanks for using this software")
	print("IGEM TecCEM_HS")
	print("SDSseeker")
	sleep(10)
def surfacePH():
	print("You selected to calculate the estimated PH")
	print("basing on the surface of Lago de Guadalupe")
	surfaceselection=""
	while surfaceselection!="g" and surfaceselection!="c":
		print("To see the general graph press:g")
		print("To calculate the PH on an specific point press:c")
		surfaceselection=str(input("Type your selection: "))
	if surfaceselection=="c":
		error=True
		while error==True:
			print("Plesase enter the distance (in m) away from the dam for which you want to know the PH")
			distance=input("pease enter the distance (only numbers): ")
			try:
				distance=float(distance)
				error=False
			except:
				print('Please enter a valid number')
				error=True
		resultsurface=surfaceformula(distance)
		print("The predicted PH for "+str(distance)+"m away the dam will be:")
		print(str(resultsurface))
		sleep(10)
	else:
		surfacegraph()
	print("")
	print("Data baed on the article:")
	print("The impact of anthropogenic pollution on limnological")
	print("characteristics of a subtropical highland reservoir") 
	print("'Lago de Guadalupe', Mexico")
	print("by:")
	print("A. Sepulveda-Jauregui, J. Hoyos-Santillan, F.J. Gutierrez-Mendieta,")
	print("R. Torres-Alvarado, L. Dendooven, F. Thalasso,")
	sleep(5)
def surfaceformula(d):
	sformularesult=(.05*math.cos((2*math.pi*d)/3858))+7.95
	return sformularesult
def surfacegraph():
	graphing.reset()
	print("x-axis= distance from the dam")
	print("y-axis= PH")
	graphing.speed("fastest")
	graphing.up()
	graphing.goto(-385.8,-8*30)
	graphing.write("Dam (0m)", align="center",font=("Arial",12,"normal"))
	graphing.goto((1929*0.1-385.8),0-8*30)
	graphing.write("Transitional area", align="center",font=("Arial",12,"normal"))
	graphing.goto((3858*0.1-385.8),0-8*30)
	graphing.write("Fluvial area (3858m)", align="center",font=("Arial",12,"normal"))
	graphing.goto(0-385.8,(7*30-8*30))
	graphing.write("7", align="center",font=("Arial",12,"normal"))
	graphing.goto(0-385.8,(8*30-8*30))
	graphing.write("8", align="center",font=("Arial",12,"normal"))
	graphing.goto(0-385.8,8*30-8*30)
	graphing.down()
	for point in range(3858):
		phsurface=(.05*math.cos((2*math.pi*point)/3858))+7.95
		graphing.goto((point*0.1-385.8),(phsurface*30-8*30))
	sleep(5)
def deepPH():
	print("You selected to calculate the estimated PH")
	print("basing on the deep of Lago de Guadalupe")
	print("(only for the area near the dam)")
	deepselection=""
	while deepselection!="g" and deepselection!="c":
		print("To see the general graph press:g")
		print("To calculate the PH on an specific deep press:c")
		deepselection=str(input("Type your selection: "))
	if deepselection=="c":
		error=True
		while error==True:
			print("Plesase enter the deep (in m) for which you want to know the PH")
			deep=input("pease enter the deep (only numbers): ")
			try:
				deep=float(deep)
				error=False
			except:
				print('Please enter a valid number')
				error=True
		resultdeep=deepformula(deep)
		print("The predicted PH for "+str(deep)+"m of deep will be:")
		print(str(resultdeep))
		sleep(10)
		print("")
		print("Data baed on the article:")
		print('"The impact of anthropogenic pollution on limnological"')
		print("characteristics of a subtropical highland reservoir") 
		print("'Lago de Guadalupe', Mexico")
		print("by:")
		print("A. Sepulveda-Jauregui, J. Hoyos-Santillan, F.J. Gutierrez-Mendieta,")
		print("R. Torres-Alvarado, L. Dendooven, F. Thalasso,")
	else:
		deepgraph()
		print("")
		print("Data baed on the article:")
		print('"The impact of anthropogenic pollution on limnological"')
		print("characteristics of a subtropical highland reservoir") 
		print("'Lago de Guadalupe', Mexico")
		print("by:")
		print("A. Sepulveda-Jauregui, J. Hoyos-Santillan, F.J. Gutierrez-Mendieta,")
		print("R. Torres-Alvarado, L. Dendooven, F. Thalasso,")
def deepformula(d):
	dformularesult=(math.exp(-0.1354461819*d))+7
	return dformularesult
def deepgraph():
	graphing.reset()
	print("X-axis= deep")
	print("Y-axis= PH")
	graphing.speed("fastest")
	graphing.up()
	graphing.goto(-17*30,-8*30)
	graphing.write("0 m (epilimnion)",align="center",font=("Arial",12,"normal"))
	graphing.goto(5*30-17*30,0-8*30)
	graphing.write("5 m",align="center",font=("Arial",12,"normal"))
	graphing.goto(10*30-17*30,0-8*30)
	graphing.write("10 m",align="center",font=("Arial",12,"normal"))
	graphing.goto(14*30-17*30,0-8*30)
	graphing.write("14 m",align="center",font=("Arial",12,"normal"))
	graphing.goto(17*30-17*30,0-8*30)
	graphing.write("17 m (Hypolimnion)",align="center",font=("Arial",12,"normal"))
	graphing.goto(0-17*30,7*30-8*30)
	graphing.write("7", align="center",font=("Arial",12,"normal"))
	graphing.goto(0-17*30,8*30-8*30)
	graphing.write("8", align="center",font=("Arial",12,"normal"))
	graphing.goto(0-17*30,0)
	graphing.down()
	for deepm in range(17):
		PHdeep=(math.exp(-0.1354461819*deepm)+7)
		graphing.goto(deepm*30-17*30,PHdeep*30-8*30)
def degradation():
	print("You selected to calculate the estimated percentage")
	print("of SDS in a solution with akylsulfatse at 30 C")
	error=True
	while error==True:
		startpercentage=input("Enter the percentage of SDS in your solution: ")
		try:
			startpercentage=float(startpercentage)
			error=False
		except:
			error=True
			print("please enter a valid number")
	degradationselection=""
	while degradationselection!="g" and degradationselection!="c":
		print("")
		print("To show the degradation graph type: g")
		print("To calculate the percentage of SDS after some time, type: c")
		degradationselection=str(input("Type your selection: "))
	if degradationselection=="c":
		error2=True
		while error2==True:
			degradationtime=input("Enter the time (in hours), for which you want to calculate: ")
			try:
				degradationtime=float(degradationtime)
				error2=False
			except:
				error2=True
				print("Please enter a valid number")
		degradationresult=degradationformula(startpercentage,degradationtime)
		print("The percentage of SDS in a solution that has "+str(startpercentage)+"% of SDS at the beginning")
		print("After "+str(degradationtime)+" hours, will have:")
		print(str(degradationresult)+"% of SDS")
		print("")
		print("Data obtained from the article:")
		print('"Regulation of the sdsA alkyl sulfatase of Pseudomonas sp.')
		print('ATCC19151 and its involvement in degradation of anionic surfactants"')
		print("by:")
		print("B. Jovcic, V. Venturi, J. Davison, L. Topisirovic and M. Kojic")
	else:
		degradationgraph(startpercentage)
		print("")
		print("Data obtained from the article:")
		print('"Regulation of the sdsA alkyl sulfatase of Pseudomonas sp.')
		print('ATCC19151 and its involvement in degradation of anionic surfactants"')
		print("by:")
		print("B. Jovcic, V. Venturi, J. Davison, L. Topisirovic and M. Kojic")
def degradationformula(s,t):
	degradationr=s*(math.exp(-0.1155*t))
	return degradationr
def degradationgraph(s):
	graphing.reset()
	print("Graph showing degradation of SDS during 48 hours")
	print("X-axis=time in hours")
	print('Y-Axis=percentage of SDS prencent')
	graphing.up()
	if 5<s<=10:
		graphing.goto(-20*10,-5*50)
		graphing.write("0 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(24*10-20*10,0-5*50)
		graphing.write("24 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(48*10-20*10,0-5*50)
		graphing.write("48 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,5*50-5*50)
		graphing.write("5%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,10*50-5*50)
		graphing.write("10%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,s*50-5*50)
		graphing.down()
		for point in range(48):
			SDSresult=s*(math.exp(-0.1155*point))
			graphing.goto(point*10-20*10,SDSresult*50-5*50)
	elif 10<s<=50:
		graphing.goto(-20*10,-25*10)
		graphing.write("0 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(24*10-20*10,0-25*10)
		graphing.write("24 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(48*10-20*10,0-25*10)
		graphing.write("48 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,25*10-25*10)
		graphing.write("25%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,50*10-25*10)
		graphing.write("50%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,s*10-25*10)
		graphing.down()
		for point in range(48):
			SDSresult=s*(math.exp(-0.1155*point))
			graphing.goto(point*10-20*10,SDSresult*10-25*10)
	elif s<=5:
		graphing.goto(10*10-20*10,-2.5*100)
		graphing.write("0 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(24*10-20*10,0-2.5*100)
		graphing.write("24 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(48*10-20*10,0-2.5*100)
		graphing.write("48 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,2.5*100-2.5*100)
		graphing.write("2.5%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,5*100-2.5*100)
		graphing.write("5%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,s*100-2.5*100)
		graphing.down()
		for point in range(48):
			SDSresult=s*(math.exp(-0.1155*point))
			graphing.goto(point*10-20*10,SDSresult*100-2.5*100)
	else:
		graphing.goto(-20*10,-50*5)
		graphing.write("0 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(24*10-20*10,0-50*5)
		graphing.write("24 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(48*10-20*10,0-50*5)
		graphing.write("48 h",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,50*5-50*5)
		graphing.write("50%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,100*5-50*5)
		graphing.write("100%",align="center",font=("Arial",12,"normal"))
		graphing.goto(0-20*10,s*5-50*5)
		graphing.down()
		for point in range(48):
			SDSresult=s*(math.exp(-0.1155*point))
			graphing.goto(point*10-20*10,SDSresult*5-50*5)
def degradationPH():
	print("You selected to calculate the estimated PH")
	print("of a solution with 5% of SDS and akylsulfatse at 30 C")
	degradationphselection=""
	while degradationphselection!="g" and degradationphselection!="c":
		print("")
		print("To show the degradation graph type: g")
		print("To calculate the PH of the solution after some time, type: c")
		degradationphselection=str(input("Type your selection: "))
	if degradationphselection=="c":
		error2=True
		while error2==True:
			degradationphtime=input("Enter the time (in hours), for which you want to calculate: ")
			try:
				degradationphtime=float(degradationphtime)
				error2=False
			except:
				error2=True
				print("Please enter a valid number")
		degradationphresult=degradationphformula(degradationphtime)
		print("The PH of a solution that has 5% of SDS at the beginning")
		print("After "+str(degradationphtime)+" hours, will have a PH of:")
		print(str(degradationphresult))
		print("")
		print("Data obtained from the article:")
		print('"Regulation of the sdsA alkyl sulfatase of Pseudomonas sp.')
		print('ATCC19151 and its involvement in degradation of anionic surfactants"')
		print("by:")
		print("B. Jovcic, V. Venturi, J. Davison, L. Topisirovic and M. Kojic")
	else:
		degradationphgraph()
		print("")
		print("Data obtained from the article:")
		print('"Regulation of the sdsA alkyl sulfatase of Pseudomonas sp.')
		print('ATCC19151 and its involvement in degradation of anionic surfactants"')
		print("by:")
		print("B. Jovcic, V. Venturi, J. Davison, L. Topisirovic and M. Kojic")
def degradationphformula(t):
	degradationphr=(2.5*math.exp(-0.1155*t))+5.5
	return degradationphr
def degradationphgraph():
	graphing.reset()
	print("Graph showing the PH of the solution during 48 hours")
	print("X-axis=time in hours")
	print('Y-Axis=PH')
	graphing.up()
	graphing.goto(-20*10,-5*50)
	graphing.write("0 h",align="center",font=("Arial",12,"normal"))
	graphing.goto(24*10-20*10,0-5*50)
	graphing.write("24 h",align="center",font=("Arial",12,"normal"))
	graphing.goto(48*10-20*10,0-5*50)
	graphing.write("48 h",align="center",font=("Arial",12,"normal"))
	graphing.goto(0-20*10,5*50-5*50)
	graphing.write("5",align="center",font=("Arial",12,"normal"))
	graphing.goto(0-20*10,8*50-5*50)
	graphing.write("8",align="center",font=("Arial",12,"normal"))
	graphing.goto(0-20*10,8*50-5*50)
	graphing.down()
	for point in range(48):
		SDSresultph=(2.5*math.exp(-0.1155*point))+5.5
		graphing.goto(point*10-20*10,SDSresultph*50-5*50)
main()